import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { wecharPriceModelListData } from '/@/api/setting/pricemodel/wecharPriceModel';
import { wecharPriceSystemTreeData } from '/@/api/setting/pricemodel/wecharPriceSystem';

const { t } = useI18n('setting.pricemodel.wecharPriceModel');

const modalProps = {
  title: t('模板维护选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  showResetButton:false,
  schemas: [
    {
      label: t('模板编号'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('模板名称'),
      field: 'name',
      component: 'Input',
    },
    {
      label: t('价格体系'),
      field: 'sysCode',
      // fieldLabel: 'price.name',
      component: 'TreeSelect',
      componentProps: {
        api: wecharPriceSystemTreeData,
        params: {status:'0' },
        allowClear: true,
      },
    },
    {
      label: t('创建人'),
      field: 'createByName',
      component: 'Input',
    },
    {
      label: t('状态'),
      field: 'status',
      component: 'Select',
      componentProps: {
        dictType: 'sys_search_status',
        allowClear: true,
      },
    },
    {
      label: t('模板说明'),
      field: 'remarks',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('模板编号'),
    dataIndex: 'code',
    key: 'a.code',
    sorter: true,
    width: 100,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('模板名称'),
    dataIndex: 'name',
    key: 'a.name',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('价格体系'),
    dataIndex: 'priceSys.name',
    key: 'a.sys_code',
    sorter: true,
    width: 150,
    align: 'left',
  },
  {
    title: t('模板说明'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 200,
    align: 'left',
  },
  {
    title: t('创建时间'),
    dataIndex: 'createDate',
    key: 'a.create_date',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('创建人'),
    dataIndex: 'createByName',
    key: 'a.create_by_name',
    sorter: true,
    width: 80,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'status',
    key: 'a.status',
    sorter: true,
    width: 80,
    align: 'center',
    dictType: 'sys_search_status',
  },
  
];

const tableProps: BasicTableProps = {
  api: wecharPriceModelListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    //params['ope'] = '1';
    return params;
  },
  ellipsis:false,
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'code',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'name',
};
